package com.battle.pojo.valid;

import com.battle.pojo.validation.PasswordValidation;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 【描 述】：
 * 【环 境】：J2SE 17
 * 【详 细】：
 *
 * @author 李松林
 * @version v1.0 2023/11/24 新建
 * @since 2023/11/24
 */
@Documented
@Constraint(validatedBy = PasswordValidation.class)
@Target({FIELD})
@Retention(RUNTIME)
public @interface Password {


    /**
     * 正则匹配规则
     * <p>
     *
     * @return
     */
//    String pattern() default "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,12}$";
    String pattern() default "^[A-Za-z\\d@$!%*?&]{8,12}$";


    /**
     * 提示
     *
     * @return
     */
    String message() default "密码格式错误";


    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

}
